package com.itheima.charstream;

import java.io.*;
import java.nio.charset.Charset;
/*
使用字符缓冲流复制文本文件
 */
public class Test02 {

    public static void main(String[] args) throws IOException {
        //创建输入流
        BufferedReader reader = new BufferedReader(new FileReader("D:\\斗罗大陆.txt", Charset.forName(
                "GBK"
        )));
        //创建输出流
        BufferedWriter writer = new BufferedWriter(new FileWriter("day13\\douluo.txt",Charset.forName(
                "GBK")));
        long start = System.currentTimeMillis();
        //循环读写
        char[] chars=new char[1024] ;
        int len;
        while ((len=reader.read(chars))!=-1){
            writer.write(chars,0,len);
        }
        long end = System.currentTimeMillis();
        System.out.println(end-start);
        //关流
        reader.close();
        writer.close();


    }
}
